﻿<navigation:Page x:Class="Corina.Lantern.Hub.Views.Login"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:be="clr-namespace:Corina.Interactivity.Silverlight;assembly=Corina.Interactivity.Silverlight"
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                 xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
                 xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                 xmlns:localViewmodel="clr-namespace:Corina.Lantern.Hub.Viewmodels"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
                 xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
                 Style="{StaticResource PageStyle}"
                 d:DesignHeight="480"
                 d:DesignWidth="960"
                 mc:Ignorable="d">
    <navigation:Page.DataContext>
        <localViewmodel:LoginViewmodel />
    </navigation:Page.DataContext>

    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
            <ei:CallMethodAction MethodName="UILoaded" TargetObject="{Binding}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>

    <navigation:Page.Resources>
        <Storyboard x:Name="StoryboardOpacity">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="imageViewer" Storyboard.TargetProperty="(UIElement.Opacity)">
                <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                <EasingDoubleKeyFrame KeyTime="0:0:1" Value="1" />
                <EasingDoubleKeyFrame KeyTime="0:0:2" Value="1" />
                <EasingDoubleKeyFrame KeyTime="0:0:3" Value="0" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>

        <Storyboard x:Name="StoryboardLogin">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="loginGrid" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)">
                <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="-90" />
            </DoubleAnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="loginGrid" Storyboard.TargetProperty="(UIElement.Visibility)">
                <DiscreteObjectKeyFrame KeyTime="0">
                    <DiscreteObjectKeyFrame.Value>
                        <Visibility>Visible</Visibility>
                    </DiscreteObjectKeyFrame.Value>
                </DiscreteObjectKeyFrame>
                <DiscreteObjectKeyFrame KeyTime="0:0:0.1">
                    <DiscreteObjectKeyFrame.Value>
                        <Visibility>Collapsed</Visibility>
                    </DiscreteObjectKeyFrame.Value>
                </DiscreteObjectKeyFrame>
            </ObjectAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="busyIndicator" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)">
                <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="-90" />
                <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="-0" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </navigation:Page.Resources>

    <toolkit:BusyIndicator Name="busyIndicator"
                           BusyContent="请稍候..."
                           IsBusy="{Binding IsBusy}">
        <Grid x:Name="LayoutRoot">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <Grid Width="500"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Top">
                <Image Name="imageViewer">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="ImageOpened">
                            <ei:ControlStoryboardAction Storyboard="{StaticResource StoryboardOpacity}" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </Image>
                <ListBox HorizontalAlignment="Right"
                         VerticalAlignment="Bottom"
                         ItemsSource="{Binding SlideCollection}"
                         SelectedItem="{Binding SelectedSlide,
                                                Mode=TwoWay}"
                         Style="{StaticResource NoframeListboxStyle}">
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <VirtualizingStackPanel Orientation="Horizontal" />
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                    <ListBox.ItemContainerStyle>
                        <Style TargetType="ListBoxItem">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="ListBoxItem">
                                        <Grid>
                                            <VisualStateManager.VisualStateGroups>
                                                <VisualStateGroup x:Name="SelectionStates">
                                                    <VisualState x:Name="Unselected" />
                                                    <VisualState x:Name="Selected">
                                                        <Storyboard>
                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="border" Storyboard.TargetProperty="(Control.Background)">
                                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                                    <DiscreteObjectKeyFrame.Value>
                                                                        <SolidColorBrush Color="Orange" />
                                                                    </DiscreteObjectKeyFrame.Value>
                                                                </DiscreteObjectKeyFrame>
                                                            </ObjectAnimationUsingKeyFrames>
                                                        </Storyboard>
                                                    </VisualState>
                                                </VisualStateGroup>
                                            </VisualStateManager.VisualStateGroups>
                                            <Border Name="border"
                                                    Width="10"
                                                    Height="10"
                                                    Margin="2"
                                                    Background="#80000000"
                                                    BorderThickness="0"
                                                    CornerRadius="5" />
                                        </Grid>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </ListBox.ItemContainerStyle>
                </ListBox>
            </Grid>

            <Grid Name="loginGrid"
                  Grid.Column="1"
                  HorizontalAlignment="Stretch">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <StackPanel Margin="0,50,0,0" HorizontalAlignment="Center">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="auto" />
                            <ColumnDefinition Width="300" />
                        </Grid.ColumnDefinitions>
                        <TextBlock VerticalAlignment="Center"
                                   Foreground="Black"
                                   Text="账  户：" />
                        <TextBox x:Name="txt_account"
                                 Grid.Column="1"
                                 Text="{Binding LoginAccount,
                                                Mode=TwoWay,
                                                UpdateSourceTrigger=PropertyChanged}">
                            <i:Interaction.Triggers>
                                <be:TextBoxEnterKeyTrigger>
                                    <be:ExecuteCommandAction Command="{Binding LoginCommand}" />
                                </be:TextBoxEnterKeyTrigger>
                            </i:Interaction.Triggers>
                        </TextBox>
                    </Grid>
                    <Grid Margin="0,12">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="auto" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <TextBlock VerticalAlignment="Center"
                                   Foreground="Black"
                                   Text="密  码：" />
                        <PasswordBox x:Name="txt_password"
                                     Grid.Column="1"
                                     Password="{Binding LoginPassword,
                                                        Mode=TwoWay,
                                                        UpdateSourceTrigger=PropertyChanged}">
                            <i:Interaction.Triggers>
                                <be:PasswordBoxEnterKeyTrigger>
                                    <i:InvokeCommandAction Command="{Binding LoginCommand}" />
                                </be:PasswordBoxEnterKeyTrigger>
                            </i:Interaction.Triggers>
                        </PasswordBox>
                    </Grid>

                    <CheckBox Margin="50,12"
                              Content="记住我的帐号"
                              IsChecked="{Binding RemberAccount,
                                                  Mode=TwoWay}" />
                </StackPanel>

                <HyperlinkButton Grid.Row="1"
                                 Margin="0,0,24,0"
                                 HorizontalAlignment="Left"
                                 VerticalAlignment="Center"
                                 Command="{Binding GotoRegisterCommand}"
                                 Content="注册新账户" />


                <StackPanel Grid.Row="1"
                            Margin="0,24"
                            HorizontalAlignment="Right"
                            Orientation="Horizontal">


                    <Button Width="75"
                            Margin="12,0"
                            Command="{Binding LoginCommand}"
                            Content="登录"
                            Style="{StaticResource OrangeButton}" />

                    <Button Width="75"
                            HorizontalAlignment="Right"
                            Click="CancelButton_Click"
                            Content="取消" />
                </StackPanel>

            </Grid>
        </Grid>
    </toolkit:BusyIndicator>


</navigation:Page>
